/*
 * @Author: your name
 * @Date: 2021-09-15 10:43:13
 * @LastEditTime: 2021-09-16 13:33:37
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \media_system\db\models\user.js
 */
//饮食记录
var moment = require('moment');
module.exports = (sequelize, DataTypes) => {
  const DietRecord = sequelize.define('dietRecord', {
    dietRecordId: {
      type: DataTypes.UUID,
      primaryKey: true,
      defaultValue: DataTypes.UUIDV4,
      comment: '饮食ID'
    },
    dietRecordName: {
      type: DataTypes.STRING,
      comment: '饮食名称'
    },
    category: {
      type: DataTypes.INTEGER,
      comment: '就餐类别（0 早餐，1午餐，2晚餐  3宵夜）'
    },
    form: {
      type: DataTypes.INTEGER,
      comment: '就餐形式（0在家 1外出）'
    },
    createdAt: {
      type: DataTypes.DATE,
      get() {
        const createdAt = this.getDataValue('createdAt')
       return moment(createdAt).format('YYYY-MM-DD HH:mm:ss');
      },
      set(createdAt) {
        return this.setDataValue('createdAt',createdAt)
      }
    },
    updatedAt: {
      type: DataTypes.DATE,
      get() {
        const updatedAt = this.getDataValue('updatedAt')
       return moment(updatedAt).format('YYYY-MM-DD HH:mm:ss');
      },
      set(updatedAt) {
        return this.setDataValue('updatedAt',updatedAt)
      }
    }
  },
    {
      tableName: 'dietRecords',
      timestamps: true
    });

  return DietRecord
}





